﻿@{
    Layout = null;
    if (!UrlData.Any()) {
        @:달력이 지정되지 않음
        return;
    }
    if (UrlData.Count < 2) {
        @:달력 ID 또는 해시가 지정되지 않음
    }

    int calendarId = System.IO.Path.GetFileNameWithoutExtension(UrlData[0]).AsInt();

    var calendar = Calendar.GetCalendarByHash(calendarId, UrlData[1]);

    if (calendar == null) {
        @:달력 ID 또는 해시가 잘못됨
        return;
    }

    var icsCalendar = IcsHelper.BuildCalendar(calendar.Id);

    Response.ClearContent();
    Response.AppendHeader("Content-Type", "application/octet-stream");// "text/calendar");
    Response.AppendHeader("Content-Disposition:", String.Format("attachment; filename={0}", HttpUtility.UrlPathEncode(calendar.Name + ".ics")));
    Response.Write(icsCalendar.ToString());
    return;
}